import React, { useState } from 'react';
import CommonModal from '@/components/CommonModal';
import CommonLoading from '@/components/CommonLoading';
import { Input, Form, message, Radio } from 'antd';
import { layout1 } from '@/utils/config';
// import { saveOfflineStore } from '@/services/common';
// import { history } from 'umi';
import Iconfont from '@/components/IconFont';
import { Base64 } from 'js-base64';

export default ({ visible, handleVisible, handleOk }) => {
  const [form] = Form.useForm();
  const [loading, setLoading] = useState(false);

  // const handleSubmit = async () => {
  //   setLoading(true);
  //   const { storeName, offlineExpressPlatform } = form.getFieldsValue();
  //   const res = await saveOfflineStore({
  //     storeName,
  //     offlineExpressPlatform,
  //     type: 0,
  //   });
  //   setLoading(false);
  //   if (res.success) {
  //     message.success('添加成功！');
  //     history.go(0);
  //   }
  // };

  const onOk = () => {
    form.validateFields().then((val) => {
      // const value = Base64.encode(val)
      // handleOk(value);
      handleOk(val)
    });
  };

  return (
    <CommonModal
      title="编辑名称"
      visible={visible}
      onCancel={() => handleVisible(false)}
      onOk={onOk}
      width="600px"
    >
      <Form {...layout1} form={form} name="add-offline-store">
        <div style={{ margin: '10px 0 30px 0', display: 'flex', flexDirection: 'row', justifyContent: 'space-between' }}>
          <span><Iconfont type='icontishicontent' style={{ margin: '3px 3px 0px 8px' }} /></span>
          <div style={{ marginLeft: 5 }}>京东云仓店铺授权只为获取接口和仓库订单导入运单号信息使用，不会同步商品或同步订单</div>
        </div>
        <Form.Item
          name="storeName"
          label="京东云仓店铺名"
          rules={[{ required: true, message: '店铺名不能为空' }, { max: 15, message: '不能超过15个字符' }]}
        >
          <Input placeholder="请输入京东云仓的店铺名" />
        </Form.Item>
      </Form>
      <CommonLoading loading={loading} />
    </CommonModal>
  );
};
